In the fields of computer hardware and software technology, it is possible in various runtime environments to modify how a method, function, class, or other such software component maps to the actual code implementation of the component. Sometimes referred to as swizzling, such re-mapping technology allows code associated with one function to be replaced by code associated with another function. This may be useful in the context of making modifications to a user interface, for example.
Some implementations of re-mapping technology involve modifying the value of a pointer that points to a location in memory where a method is implemented in code. By changing the value of the pointer, the method can be made to point to other code such that, when the method is called, a different method is employed in its place. The target method that is called in place of the original method is sometimes referred to as a callback function.
In order to swizzle multiple functions, multiple callback functions are typically created that each correspond to one of the multiple functions, which allows the callback functions to call back into the original functions with little difficulty. For instance, one original function may be remapped to jump to one callback function, while another original function may be remapped to jump to another, different call back function, and so on for the remainder of the original and callback functions as they correspond to each other.
Code optimization technology employed in some runtime environments can make code re-mapping difficult, if not impossible. For example, one runtime environment reduces the prominence of the v-table, or dispatch table, which reduces the effectiveness of remapping via pointer modifications. Pointers are still used to a certain extent, but de-virtualization and other optimization techniques that speed-up the execution of code make finding and remapping them more difficult.